package com.fhz.main.ui.home

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.fhz.common.entity.MeiNvEntity
import com.fhz.loginmvvm.callback.ApiResponse
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(private val repository: HomeRepository) : ViewModel() {

    //在闭包范围内可以任意调用该对象的任意方法,并在最后返回该对象.
    //apply函数中表示对象本身使用的是this关键字而不是it。
    private val _text = MutableLiveData<String>().apply {
        value = "This is home Fragment"
    }
    val text: LiveData<String> = _text


    //从服务器请数据
    fun getMeiNv(type:String,page:Int,size:Int) : LiveData<ApiResponse<MeiNvEntity>> {
        return repository.getMeiNv(type,page,size)
    }
}